<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <br/>
            <h3 class="title">Imóveis Pendentes</h3>
            <h:form id="pesForm" enctype="multipart/form-data">
                <p:panel id="realtyPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">

                    <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                    <p:outputLabel value="Grupo: " styleClass="grid_3"/>
                    <div class="grid_8">
                        <p:selectOneMenu value="#{managerImovel.grupo}">  
                            <f:selectItem itemLabel="GRUPO 1" itemValue="GRUPO 1" />  
                            <f:selectItem itemLabel="GRUPO 2" itemValue="GRUPO 2" />  
                            <f:selectItem itemLabel="GRUPO 3" itemValue="GRUPO 3" />  
                            <f:selectItem itemLabel="GRUPO 4" itemValue="GRUPO 4" />  
                            <f:selectItem itemLabel="GRUPO 5" itemValue="GRUPO 5" />  
                            <f:selectItem itemLabel="GRUPO 6" itemValue="GRUPO 6" />  
                            <f:selectItem itemLabel="GRUPO 7" itemValue="GRUPO 7" />  
                            <f:selectItem itemLabel="GRUPO 8" itemValue="GRUPO 8" />  
                        </p:selectOneMenu> 
                    </div>

                    <p:outputLabel value="Bairro:" styleClass="grid_3" for="bairroSelectOneMenu"/>
                    <div class="grid_8">
                        <p:selectOneMenu id="bairroSelectOneMenu" panelStyle="width:150px;" 
                                         value="#{managerImovel.bairro}" filter="true"
                                         converter="bairroconverter">
                            <f:selectItem itemLabel="" itemValue="" /> 
                            <f:selectItems value="#{managerImovel.bairros}" var="cl" itemValue="#{cl}" itemLabel="#{cl.nome}"/>
                        </p:selectOneMenu> 
                    </div>
                    <br/>
                    
                    <p:outputLabel value="Pendência:" styleClass="grid_3" 
                                   for="pendenciaSelectManyCheckbox"/>
                    <p:selectManyCheckbox id="pendenciaSelectManyCheckbox" 
                                          style="border: none !important; "
                                           value="#{managerImovel.selectedOptions}">  
                         <f:selectItems value="#{managerImovel.tipoPendencia}"/>
                     </p:selectManyCheckbox>  

                    <div class="clear"/><br/>
                    <div class="buttonAction">
                        <p:commandButton id="bt_pes" value="Pesquisar" icon="ui-icon-search"
                                         update="@form"
                                         actionListener="#{managerImovel.imovelPendente()}"
                                         styleClass="ui-priority-primary" />

                    </div >
                    <br/>
                    <p:blockUI id="BLOCK" block="realtyPanel" trigger="bt_pes" > 
                        <p:graphicImage value="media/images/ajax-loader.gif"/>
                    </p:blockUI>

                    <div id="imprimir">
                        <p:dataTable id="tableImovel" var="item" value="#{managerImovel.resultPendentes}" 
                                     styleClass="grid_24" rowIndexVar="rowid" style="font-size: 10px;"
                                     rowKey="#{item.id}" rows="6" paginator="true"
                                     paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                <p:outputLabel value="Imóvel #{managerImovel.resultPendentes.isEmpty() ? '' : '('.concat(managerImovel.resultPendentes.size()).concat(')')}" />
                            </f:facet>
                            <p:column headerText="Ação" exportable="false" width="20" style="text-align: center">
                                <p:button  style="width: 20px; height: 20px;" 
                                           title="Editar"
                                           href="editarimovel.xhtml?eImovel=#{item.id}"
                                           icon="ui-icon-pencil"/>
                                <p:button  style="width: 20px; height: 20px;" 
                                           title="Visualizar"
                                           href="visualizarimovel.xhtml?vImovel=#{item.id}"
                                           icon="ui-icon-zoomin"/>

                            </p:column>
                            <p:column >  
                                <f:facet name="header">  
                                    <h:outputText value="Inscrição Cadastral" />  
                                </f:facet>
                                <h:outputText value="#{item.inscricaoCadastralD}" >
                                    <f:convertNumber minIntegerDigits="2" type="number" />
                                </h:outputText>.
                                <h:outputText value="#{item.inscricaoCadastralS}" >
                                    <f:convertNumber minIntegerDigits="2" type="number" />
                                </h:outputText>.
                                <h:outputText value="#{item.inscricaoCadastralQuadra}" >
                                    <f:convertNumber minIntegerDigits="3" type="number" />
                                </h:outputText>.
                                <h:outputText value="#{item.inscricaoCadastralLote}" >
                                    <f:convertNumber minIntegerDigits="4" type="number" groupingUsed="false" />
                                </h:outputText>.
                                <h:outputText value="#{item.inscricaoCadastralUnid}" >
                                    <f:convertNumber minIntegerDigits="2" type="number" />
                                </h:outputText>

                            </p:column>
                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Grupo" />  
                                </f:facet>
                                <h:outputText value="#{item.groupCreate}" />
                            </p:column>
                            <p:column>
                                <f:facet name="header">  
                                    <h:outputText value="Data" />  
                                </f:facet>
                                <h:outputText value="#{item.createAt}" >
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>
                            <p:column width="200" style="white-space: pre-wrap;">  
                                <f:facet name="header">  
                                    <h:outputText value="Localização" />  
                                </f:facet>
                                <h:outputText value="Logradouro #{item.enderecoImovel.logradouro}, Nº #{item.enderecoImovel.numero}" />
                            </p:column>
                            <p:column width="100">  
                                <f:facet name="header">  
                                    <h:outputText value="Bairro" />  
                                </f:facet>
                                <h:outputText value="#{item.enderecoImovel.bairro}" />
                            </p:column>
                            <p:column  style="white-space: pre-wrap;" width="300" >  
                                <f:facet name="header">  
                                    <h:outputText value="Pendência" />  
                                </f:facet>
                                <h:outputText rendered="#{item.proprietarios.isEmpty()}" style="color: red" value="#{managerImovel.pendencias(item)}"/>
                            </p:column> 
                        </p:dataTable> 
                        <div class="buttonAction">

                            <p:commandButton value="Imprimir" 
                                             disabled="#{empty managerImovel.resultPendentes}"
                                             icon="ui-icon-search"  immediate="true" ajax="false"
                                             actionListener="#{managerImovel.relPendente()}"
                                             styleClass="ui-priority-primary" />
                        </div >
                    </div>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
